package lgq.service;

import java.util.List;

import util.Page;

import model.TrainType;

import dao.TrainTypeDAO;
import dao.impl.TrainTypeDAOImpl;

public class TrainTypeManager {
	TrainTypeDAO ttd=new TrainTypeDAOImpl();
	public List<TrainType> getAll()
	{
		return ttd.getAll();
	}
	
	public Page<TrainType> getAll(int pageNo, int pageSize) {
		return ttd.getAll(pageNo, pageSize);
	}
	public boolean ifExistName(String name)
	{
		if(null==ttd.getByName(name))
			return false;
		else
			return true;
	}
	public boolean addupdate(TrainType traintype)
	{
		return ttd.update(traintype);
	}
	public boolean deleteById(int id)
	{
		return ttd.delete(id);
	}
	public boolean add(TrainType triantype)
	{
		return ttd.add(triantype);
	}
	public boolean addByName(String name)
	{
		TrainType tt=new TrainType();
		tt.setTypename(name);
		return ttd.add(tt);
	}
	public boolean updateByIdAndName(int id,String name)
	{
		TrainType tt=new TrainType();
		tt.setId(id);
		tt.setTypename(name);
		return ttd.update(tt);
	}
	public TrainType getById(int id)
	{
		return ttd.getById(id);
	}
}
